package server

type GedisDB struct {
	Dict  map[string]string // The keyspace for this DB.
	count uint64            // The keys count.
}

// NewGedisDB initial property dict.
func NewGedisDB() *GedisDB {
	return &GedisDB{
		Dict: make(map[string]string),
	}
}

// Put add element to dict.
func (db *GedisDB) Put(key string, value string) {
	_, ok := db.Dict[key]
	if !ok {
		db.count++
	}
	db.Dict[key] = value
}

// Get get a element from dict using specified key.
func (db *GedisDB) Get(key string) string {
	value, _ := db.Dict[key]
	return value
}

// Del delete a element from dict using specified key.
func (db *GedisDB) Del(key string) {
	_, ok := db.Dict[key]
	if ok {
		db.count--
		delete(db.Dict, key)
	}
}
